using System;
using System.ComponentModel;
using System.Runtime.Serialization;
namespace Net35.Xrm.Sdk.Query
{
	[DataContract(Name = "QueryByAttribute", Namespace = "http://schemas.microsoft.com/xrm/2011/Contracts")]
	public sealed class QueryByAttribute : QueryBase
	{
		private string _entityName;
		private DataCollection<string> _attributes;
		private DataCollection<object> _attributeValues;
		private PagingInfo _pageInfo;
		private ColumnSet _columnSet;
		private DataCollection<OrderExpression> _orders;
		private int? _topCount;
		[DataMember]
		public string EntityName
		{
			get
			{
				return this._entityName;
			}
			set
			{
				this._entityName = value;
			}
		}
		[DataMember]
		public DataCollection<string> Attributes
		{
			get
			{
				if (this._attributes == null)
				{
					this._attributes = new DataCollection<string>();
				}
				return this._attributes;
			}
			private set
			{
				this._attributes = value;
			}
		}
		[DataMember]
		public DataCollection<object> Values
		{
			get
			{
				if (this._attributeValues == null)
				{
					this._attributeValues = new DataCollection<object>();
				}
				return this._attributeValues;
			}
			private set
			{
				this._attributeValues = value;
			}
		}
		[DataMember]
		public PagingInfo PageInfo
		{
			get
			{
				return this._pageInfo;
			}
			set
			{
				this._pageInfo = value;
			}
		}
		[DataMember]
		public ColumnSet ColumnSet
		{
			get
			{
				return this._columnSet;
			}
			set
			{
				this._columnSet = value;
			}
		}
		[DataMember]
		public DataCollection<OrderExpression> Orders
		{
			get
			{
				if (this._orders == null)
				{
					this._orders = new DataCollection<OrderExpression>();
				}
				return this._orders;
			}
			private set
			{
				this._orders = value;
			}
		}
		[DataMember(Order = 50)]
		public int? TopCount
		{
			get
			{
				return this._topCount;
			}
			set
			{
				this._topCount = value;
			}
		}
		public QueryByAttribute()
		{
			this._columnSet = new ColumnSet();
			this._pageInfo = new PagingInfo();
		}
		public QueryByAttribute(string entityName)
		{
			this.EntityName = entityName;
		}
		[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
		internal override void Accept(IQueryVisitor visitor)
		{
			visitor.Visit(this);
		}
		public void AddOrder(string attributeName, OrderType orderType)
		{
			this.Orders.Add(new OrderExpression(attributeName, orderType));
		}
		public void AddAttributeValue(string attributeName, object value)
		{
			this.Attributes.Add(attributeName);
			this.Values.Add(value);
		}
	}
}
